﻿using System;

namespace ExcelConfig.helpers
{
    internal partial class helper
    {
        public static int count_char(string text, char c) 
        {
            var ix = 0;
            var count = 0;
            while ((ix = text.IndexOf(c, ix)) != -1) count++;
            return count;
        }
        public static bool IsXmlChar(char ch)
        {
            // 检查基本ASCII控制字符（除制表符、换行符和回车符外）
            if (ch <= 0x1F)
            {
                return ch == 0x9 || ch == 0xA || ch == 0xD;
            }

            // 检查主要Unicode范围
            if (ch < 0xD800) return true;
            if (ch <= 0xDFFF) return false; // 代理对范围

            // 检查高代理区
            return (ch <= 0xFFFD) && (ch != 0xFFFE);
        }
    }
}
